#ifndef _H_I_PROTOCOL_HELPER_H_
#define _H_I_PROTOCOL_HELPER_H_

#include "../typedefine.h"
#include <memory>
#include "../promise.h"
#include "EProtocolErrorCode.h"

namespace QWER
{
    QCLASS IProtocolSocketImpl;
    QCLASS IProtocolAcceptorImpl;

    QDLL_EXPORT QSTRUCT SProtocolConnectRet
    {
    public:
        SProtocolConnectRet(EProtocolErrorCode eErrorCode) : m_eErrorCode(eErrorCode) {
        }
        SProtocolConnectRet(EProtocolErrorCode eErrorCode, std::unique_ptr<IProtocolSocketImpl> && roSocket) : m_eErrorCode(eErrorCode) {
            m_poSocket = std::move(roSocket);
        }
    public:
        EProtocolErrorCode m_eErrorCode = EProtocolErrorCode::Error;
        std::unique_ptr<IProtocolSocketImpl> m_poSocket;
    };

    QDLL_EXPORT QSTRUCT SProtocolListenRet
    {
    public:
        SProtocolListenRet(EProtocolErrorCode eErrorCode) : m_eErrorCode(eErrorCode) {
        }
        SProtocolListenRet(EProtocolErrorCode eErrorCode, std::unique_ptr<IProtocolAcceptorImpl> && roAcceptor) : m_eErrorCode(eErrorCode) {
            m_poAcceptor = std::move(roAcceptor);
        }
    public:
        EProtocolErrorCode m_eErrorCode = EProtocolErrorCode::Error;
        std::unique_ptr<IProtocolAcceptorImpl> m_poAcceptor;
    };

	QDLL_EXPORT QINTERFACE IProtocolHelper
	{
	public:
#ifndef _USING_CLI
		virtual ~IProtocolHelper(){
		}
#endif
		virtual CPromise<SProtocolListenRet>& Listen(UINT64 qwAddress) = 0;
		virtual CPromise<SProtocolConnectRet>& Connect(UINT64 qwAddress) = 0;
	};
}

#endif
